home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Frameworks / Grant's CGI Framework 1.0b12 / MyHandlers.c < prev    next >
Text File  |  1995-12-09  |  4KB  |  193 lines

  1. /*****
  2.  *
  3.  *    MyHandlers.c
  4.  *
  5.  *    Optional custom functions to handle special events. Includes:
  6.  *        document opening, startup and quitting
  7.  *
  8.  *    Modify these functions if you need to add to the standard support
  9.  *    built into the framework.
  10.  *
  11.  *    The function prototypes are contained in the relevent headers.
  12.  *    For example, AEHandlers.h contains the prototype for MyOpenDocument
  13.  *
  14.  *    This is a support file for "Grant's CGI Framework".
  15.  *    Please see the license agreement that accompanies the distribution package
  16.  *    for licensing details.
  17.  *
  18.  *    Copyright ©1995 by Grant Neufeld
  19.  *    grant@acm.com
  20.  *    http://arpp1.carleton.ca/grant/
  21.  *
  22.  *****/
  23.  
  24. #include "MyConfiguration.h"
  25.  
  26. #include "compiler_stuff.h"
  27.  
  28. #if kCompileWithDragNDrop
  29. #include <Drag.h>
  30. #endif
  31.  
  32. #include "AEHandlers.h"
  33. #include "CGI.h"
  34. #include "DebugUtil.h"
  35. #include "EventUtil.h"
  36. #include "ListSTAR.h"
  37. #include "Quit.h"
  38. #include "Startup.h"
  39. #include "WindowInt.h"
  40.  
  41.  
  42. /***  FUNCTIONS  ***/
  43.  
  44. #pragma segment AppleEvents
  45. /* The application is expected to open the given documents, if possible */
  46. OSErr
  47. MyOpenDocument ( FSSpec *theFile )
  48. {
  49.     OSErr    theErr;
  50.     
  51.     my_assert ( theFile != nil, "\p: theFile ptr is nil" );
  52.     
  53.     theErr = noErr;
  54.     
  55.     return theErr;
  56. } /* MyOpenDocument */
  57.  
  58.  
  59. #pragma segment Utilities
  60. /* Close any custom application windows */
  61. #if kCompileWithApplicationWindows
  62. OSErr
  63. MyCloseWindow ( WindowPtr theWindow )
  64. {
  65.     OSErr    theErr;
  66.     
  67.     theErr = noErr;
  68.     
  69.     return theErr;
  70. } /* MyCloseWindow */
  71. #endif
  72.  
  73.  
  74. /* If activate is true, restore theWindow's selections.
  75.     If activate is false, hide, or reduce to outline, theWindow's selections.
  76.     If theWindow has a grow box in the bottom right corner,
  77.     you should invalidate the growrect */
  78. #if kCompileWithApplicationWindows
  79. void
  80. MyActivateWindow ( WindowPtr theWindow, Boolean activate )
  81. {
  82.     
  83. } /* MyUpdateWindow */
  84. #endif
  85.  
  86.  
  87. /* Draw contents of window on an update event */
  88. #if kCompileWithApplicationWindows
  89. void
  90. MyUpdateWindow ( WindowPtr theWindow )
  91. {
  92.     
  93. } /* MyUpdateWindow */
  94. #endif
  95.  
  96.  
  97. /* Support a click in a window.
  98.     If the click is on a dragable item, set onDragItem to true. */
  99. #if kCompileWithApplicationWindows
  100. void
  101. MyClickInWindow ( WindowPtr theWindow, Point thePoint, Boolean *onDragItem )
  102. {
  103.     
  104. } /* MyClickInWindow */
  105. #endif
  106.  
  107.  
  108. /* If you add windows that allow for text entry or you accept non-command-key
  109.     keyboard input, you need to support this function. */
  110. #if kCompileWithKeyboardEvents
  111. void
  112. MyKeyPress ( EventRecord *theEvent )
  113. {
  114.     
  115. } /* MyKeyPress */
  116. #endif
  117.  
  118.  
  119. /*  */
  120. #if kCompileWithDragNDrop
  121. OSErr
  122. MyDoStartDrag ( EventRecord *theEvent, WindowPtr theWindow )
  123. {
  124.     OSErr            theErr;
  125.     GrafPtr            savePort;
  126.     DragReference    theDrag;
  127.     RgnHandle        dragRegion;
  128.     
  129.     GetPort ( &savePort );
  130.     SetPort ( (GrafPtr)theWindow );
  131.     
  132.     theErr = NewDrag ( &theDrag );
  133.     
  134.     if ( theErr == noErr )
  135.     {
  136.         dragRegion = NewRgn ();
  137.         
  138.         /* ••• You need to call a function that sets up the drag values such as:
  139.             theErr = customSetupDrag ( theWindow, theDrag, dragRegion, theEvent->where ); */
  140.     }
  141.     else
  142.     {
  143.         theDrag = nil;
  144.     }
  145.     
  146.     SetPort ( savePort );
  147.     
  148.     theErr = TrackDrag ( theDrag, theEvent, dragRegion );
  149.     
  150.     if ( dragRegion != nil )
  151.     {
  152.         DisposeRgn ( dragRegion );
  153.     }
  154.     
  155.     if ( theDrag != nil )
  156.     {
  157.         DisposeDrag ( theDrag );
  158.     }
  159.         
  160.     return theErr;
  161. } /* MyDoStartDrag */
  162. #endif
  163.  
  164.  
  165. #pragma segment Startup
  166. /* add things like installing additional AppleEvent handlers in this function */
  167. OSErr
  168. MyStartup ( void )
  169. {
  170.     OSErr    theErr;
  171.     
  172.     MyCGIStartup        ();    /* CGI Specific */
  173.     MyListSTARStartup    ();    /* ListSTAR Specific */
  174.     
  175.     theErr = noErr;
  176.     
  177.     return theErr;
  178. } /* MyStartup */
  179.  
  180.  
  181. #pragma segment Main
  182. /* Unless allowUserInteract is true, don't make any calls that might require
  183.     user interaction.
  184.     Return true if your clean up was successful and quitting should proceed. */
  185. Boolean
  186. MyQuit ( Boolean allowUserInteract )
  187. {
  188.     return MyCGIQuit ( allowUserInteract );
  189. } /* MyQuit */
  190.  
  191.  
  192. /*****  EOF  *****/
  193.